﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Lilium.UI.Layout;
using System.Windows.Forms;

namespace Lilium.UI.Forms
{
    public class LayoutAdapter: ControlAdapter<Panel>, ILayout<System.Windows.Forms.Control>
    {
        public LayoutAdapter(Panel control)
            : base(control)
        {
        }

        #region ILayout<Control> Members

        public void Add(System.Windows.Forms.Control control)
        {
            if (control == null) throw new ArgumentNullException("control");

            var controlCount = Control.Controls.Count;
            if (controlCount != 0)
            {
                var lastControl = Control.Controls[Control.Controls.Count - 1];
                control.Top = lastControl.Bottom;
            }
            Control.Controls.Add(control);
        }

        #endregion
    }
}
